#include "profilingleveldialog.h"

ProfilingLevelDialog::ProfilingLevelDialog(QWidget *parent) :
    QDialog(parent)
{
    profilingLevelTipsLabel=new QLabel(tr("Current selected database's profiling level is:"));
    profilingLevelLabel=new QLabel(tr("Profiling Level"));
    profilingLevelsCombo=new QComboBox();
    profilingLevelsCombo->addItem(tr("ProfileOff"),mongo::DBClientWithCommands::ProfileOff);
    profilingLevelsCombo->addItem(tr("ProfileSlow"),mongo::DBClientWithCommands::ProfileSlow);
    profilingLevelsCombo->addItem(tr("ProfileAll"),mongo::DBClientWithCommands::ProfileAll);

    okButton=new QPushButton(tr("OK"));
    cancelButton=new QPushButton(tr("Cancel"));
    QVBoxLayout* vLayout=new QVBoxLayout;
    vLayout->addWidget(profilingLevelTipsLabel);
    QHBoxLayout* hLayout1=new QHBoxLayout;
    hLayout1->addWidget(profilingLevelLabel);
    hLayout1->addWidget(profilingLevelsCombo);
    vLayout->addLayout(hLayout1);

    QHBoxLayout* hLayout2=new QHBoxLayout;
    hLayout2->addWidget(okButton);
    hLayout2->addWidget(cancelButton);
    vLayout->addLayout(hLayout2);
    setLayout(vLayout);

    setWindowTitle(tr("Database Profiling Level Edit"));
}

void ProfilingLevelDialog::SetSelectedProfiling(mongo::DBClientWithCommands::ProfilingLevel level)
{
    profilingLevelsCombo->setCurrentIndex(profilingLevelsCombo->findData(level));
}
